﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTO;
using DataService;

public partial class Billing_default : BasePage
{
    private ContactService contactService = new ContactService();
    private CreditCard CreditCard;
    private BankAccount bankAccount;
    private string PaymentType = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (UserLogin != null)
        {
            if (UserLogin.Customer.BillingContact != null)
                litAboutYou.Text = UserLogin.Customer.BillingContact.ToString();
            else
                litAboutYou.Text = "No Contact Billing ";
            PaymentType = contactService.GetAccountPaymentType(UserLogin.Customer.Id);
            if (!string.IsNullOrEmpty(PaymentType))
            {
                lbCredit.PostBackUrl = "~/Billing/EditBillingCard.aspx?Payment=" + PaymentType;
                lbBank.PostBackUrl = "~/Billing/EditBillingCard.aspx?Payment=" + PaymentType;
                hlSwitch.NavigateUrl = hlEdit.NavigateUrl = "~/Billing/EditBillingCard.aspx?Payment=" + PaymentType;
                switch (PaymentType)
                {
                    case "C":
                        CreditCard = contactService.GetCreditCardByAccountId(UserLogin.Customer.Id);
                        lblTitle.Text = "Credit Card ";
                        if (CreditCard != null)
                        {
                            litCredit.Text = CreditCard.ToString();
                        }
                        else
                        {
                            litCredit.Text = "No Card ";
                        }
                        break;
                    case "B":
                        bankAccount = contactService.GetBankAccountInfo(UserLogin.Customer.Id);
                        lblTitle.Text = "Bank Account Info";
                        if (bankAccount != null)
                        {
                            litCredit.Text = bankAccount.ToString();
                        }
                        else
                        {
                            litCredit.Text = "No Bank";
                        }
                        break;
                    default:
                        lblTitle.Text = litCredit.Text = "No Credit Card and Bank Account";
                        break;
                }
            }
        }
        else
        {
            Response.Redirect("~/Login.aspx");
        }
    }
}